import axios from '../../utils/http'

const model = {
    namespaced: true, //形成对立的命名空间
    state(){
        return{
          userList: [],
        count:0  
        }
        //数据
    },
    mutations: {
        userListMutation(state,list){
            //设置数据
            state.userList = list
        },
        userCountMutation(state,count){
            //设置数据
            state.count = count
        }
    },
    actions: {
        userListActions(context,obj){
            //请求数据
            axios.get("/userlist",{params:obj}).then(res=>{
                context.commit("userListMutation",res.list)
            })
        },
        userCountActions(context){
            //请求数据
            axios.get("/usercount").then(res=>{
                context.commit("userCountMutation",res.list[0].total)
            })
        },
    }
}

export default model